#!/usr/bin/make -f
ver = xxx

%:
	dh $@ --builddir build/ --buildsystem=cmake+ninja

NEO_DISABLE_BUILTINS_COMPILATION ?= FALSE
RELEASE_WITH_REGKEYS ?= FALSE
IGDRCL_FORCE_USE_LIBVA ?= FALSE
NEO_SKIP_UNIT_TESTS ?= FALSE
NEO_ENABLE_I915_PRELIM_DETECTION ?= FALSE
NEO_ENABLE_XE_PRELIM_DETECTION ?= FALSE
NEO_ENABLE_XE_EU_DEBUG_SUPPORT ?= FALSE
NEO_USE_XE_EU_DEBUG_EXP_UPSTREAM ?= FALSE
NEO_FORCE_USE_AUB_STREAM ?= TRUE
NEO_LEGACY_PLATFORMS_SUPPORT ?= FALSE
NEO_CURRENT_PLATFORMS_SUPPORT ?= TRUE
NEO_OCLOC_VERSION_MODE ?= 1

override_dh_auto_configure:
	dh_auto_configure -- ${NEO_BUILD_EXTRA_OPTS} \
		-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
		-DNEO_OCLOC_VERSION_MODE=${NEO_OCLOC_VERSION_MODE} \
		-DNEO_VERSION_BUILD=$(ver) \
		-DNEO_SKIP_UNIT_TESTS=${NEO_SKIP_UNIT_TESTS} \
		-DNEO_ENABLE_I915_PRELIM_DETECTION=${NEO_ENABLE_I915_PRELIM_DETECTION} \
		-DNEO_ENABLE_XE_PRELIM_DETECTION=${NEO_ENABLE_XE_PRELIM_DETECTION} \
		-DNEO_ENABLE_XE_EU_DEBUG_SUPPORT=${NEO_ENABLE_XE_EU_DEBUG_SUPPORT} \
		-DNEO_USE_XE_EU_DEBUG_EXP_UPSTREAM=${NEO_USE_XE_EU_DEBUG_EXP_UPSTREAM} \
		-DNEO_DISABLE_BUILTINS_COMPILATION=${NEO_DISABLE_BUILTINS_COMPILATION} \
		-DNEO_LEGACY_PLATFORMS_SUPPORT=${NEO_LEGACY_PLATFORMS_SUPPORT} \
		-DNEO_CURRENT_PLATFORMS_SUPPORT=${NEO_CURRENT_PLATFORMS_SUPPORT} \
		-DNEO_BUILD_WITH_OCL=FALSE \
		-DRELEASE_WITH_REGKEYS=${RELEASE_WITH_REGKEYS} \
		-DIGDRCL_FORCE_USE_LIBVA=${IGDRCL_FORCE_USE_LIBVA} \
		-DNEO_FORCE_USE_AUB_STREAM=${NEO_FORCE_USE_AUB_STREAM} \
		-DL0_INSTALL_UDEV_RULES=1 \
		-DUDEV_RULES_DIR=/etc/udev/rules.d/ \
		-Wno-dev

override_dh_auto_build:
	${BUILD_PREFIX} dh_auto_build

override_dh_install:
	rm -rf debian/intel-level-zero-gpu/etc/
	rm -rf debian/intel-level-zero-gpu/usr/lib/${DEB_TARGET_MULTIARCH}/intel-opencl/
	rm -rf debian/intel-level-zero-gpu/usr/bin/
	rm -rf debian/intel-level-zero-gpu/usr/include/ocloc_api.h
	rm -rf debian/intel-level-zero-gpu/usr/lib/${DEB_TARGET_MULTIARCH}/libocloc.so
	rm -rvf debian/intel-level-zero-gpu/usr/lib/debug
	dh_install
	if [ -d "${NEO_NINJA_DUMP}" ]; then find -name .ninja_\* -type f -exec cp -v {} ${NEO_NINJA_DUMP}/ \;; fi

override_dh_auto_test:
	echo "ULTs already executed"
